<?php
#Header of each admin page
function head_admin($title=""){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<?=HTML_BASE_ADMIN?>"></base>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$title?></title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="images/favicon.ico" />
<link  href="<?=HTML_BASE_ADMIN?>css/jquery-tab.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="<?=HTML_BASE_ADMIN?>fancybox/jquery.fancybox-1.3.1.css" media="screen" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="<?=HTML_BASE_ADMIN?>js/script.js"></script> 
<script src="<?=HTML_BASE_ADMIN?>js/tabs.js"></script>

</head>
<body>
<div id="wrap" class="clearfix">

<div id="wraptop" class="clearfix">
	<div id="top">
		<div id="topleft">
			<h2><a href="index.php" title="Към начална страница"><?=DOMAIN_NAME?>/администрация</a></h2>
		</div><!--END: topleft-->
		<div id="topright">
			
			<? if ($_SESSION['USERNAME']) { ?>
			Здравей <?=$_SESSION['USERNAME']?>, <a href="../logout.php">изход</a>
			<? } ?>
		</div><!--END: topright-->
        
        
        
        
	</div><!--END: top-->
</div><!--END: wraptop-->

<div id="wrapin" class="clearfix">
	<div id="content">
		<div id="left">
			
<?php
}

# Footer of each admin page
function foot_admin(){
?>
</div><!--END: left-->
        
        <div id="version">
            <span class="version"><a href="<?=HTML_BASE?>" target="_blank">преглед на сайта &raquo;</a></span>
        </div>
        <div id="right">
            <ul class="menu">
            		<li><a href="projects.php">Проекти</a>
                    	<ul>
                        <?php 
							$sql = "SELECT
							c.category_id,
							c.order_number,
							c.published,
							
							d.Name
							
							
						FROM
							category AS c,
							category_description AS d
						WHERE
						
							c.category_id = d.category_id
							
							AND
							
							d.lang_id = '1'
							
							AND c.type = 'project'
							
							ORDER BY  c.order_number DESC
						  ";
						 $result = query($sql);
						 
						 while ($row = mysql_fetch_object($result)) {
							 $active = '';
							 
							 if($_GET['cat_id'] == $row->category_id) $active = ' class = "active" ';
						?>
                         <li><a <?=$active?> href="projects.php?cat_id=<?=$row->category_id?>"><?=$row->Name?></a></li>
                        <?php }?>
                        </ul>
                    
                    </li>
                    <li><a href="category.php">Категории проекти</a></li>
                    
                    <li><a href="pages.php">Страници</a></li>
                    <li><a href="menus.php">Меню</a></li>
                    
                    <li><a href="users.php">Потребители</a></li>
               
            </ul>
        </div><!--END: right-->
		<div id="version">
            <span class="version">
			website: <?=DOMAIN_NAME?><br />
			версия <?=VERSION?><br/><br/><br/>
			</span>
        </div>
		
    </div><!--END: content-->
</div><!--END: wrapin-->

<div id="footerwrap" class="clearfix">
    <div id="footer">
        &copy; Административна система от <a href="http://studiokipo.com" target="_blank">Студио Кипо</a>
	</div><!--END: footer-->
</div><!--END: footerwrap-->

</div><!--END: wrap-->

</body>
</html>
<?php
}

#Confirm the updates
function controls($previous="", $formID="") {
?>

 <div id="bottomLine"> 
       <a class="button" id="only-save">Запиши</a>
       <a class="button" id="close-save">Запиши и затвори</a>
       <a class="button grey" href="<?=$previous?>">Отказ</a>
 </div> 
    
<script >
 var unsaved = false;

 $(document).ready(function(){
	
	$("#close-save").click(function(){
		unsaved = false;
		$("#redirectForm").val("<?=$previous?>");
		$("<?=$formID?>").submit();
		
	});
	
	$("#only-save").click(function(){
		unsaved = false;
		//$("#redirectForm").val("<?=$current?>");
		$("<?=$formID?>").submit();
	});
	
 });


 $(":input").change(function(){ //trigers change in all input fields including text type
    unsaved = true;
 });

 $(window).bind('beforeunload', function(){
  if(unsaved) return 'Не сте записали направените промени!';
  
 });

</script>


<?php
}
?>